﻿@model KPIS.GERP.Models.FIM.MasBankAccount

@{
    ViewBag.Title = ViewBag.TitleNav = "แก้ไข \"" + Model.Name + "\"";
}

@using (Html.BeginForm("Edit", "MasBankAccount", FormMethod.Post, new { @class = "form-horizontal" }))
{
    @Html.AntiForgeryToken()

    <div class="block-button-menu-above">
        @Html.ButtonViewAll()
        @Html.ButtonSubmit()
        @Html.ActionLink("ยกเลิก", "Index", new { id = Model.BankAccId }
                        , new { @class = "btn btn-danger button-standard-width btn-small", role = "button" })
    </div>
    
    @Html.ValidationSummary(true, "", new { @class = "alert alert-error" })
    @Html.Partial("_EditorForm")
}

@section scripts
{
    <script>
        $("form").submit(function (e) {
            e.preventDefault();
            var currentForm = this;
            bootbox.confirm(function (result) {
                if (result) {
                    currentForm.submit();
                }
            });
        });

        $("#BankId").change(function () {
            var id = $('#BankId').val();

            if (id != '') {
                $.getJSON('BankBrabchList?BankId=' + id, function (data) {
                    $('#BranchId').empty();
                    $.each(data, function (i, result) {
                        $('#BranchId').append("<option value='" + result.Value + "'>" + result.Text + "</option>");
                    });
                    $("#BranchId").trigger("liszt:updated");//update list
                });
            }
            else {

            }
        });
    </script>
}